<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>这个月有几天</title>
    <script>
        function wd() {
            let y = prompt("请输入年份");

            if (isNaN(y)) {
                alert("请输入数字");
                return
            } else {
                y = parseInt(y)
            }
            let m = prompt("请输入月份");
            if (isNaN(m)) {
                alert("请输入数字");
                return
            } else {
                m = parseInt(m)
            }
            switch (m) {
                case 1:
                case 3:
                case 5:
                case 7:
                case 8:
                case 10:
                case 12: {
                    alert(y + "年" + m + "月有31天");
                    break;
                }
                case 4:
                case 6:
                case 9:
                case 11: {
                    alert(y + "年" + m + "月有30天");
                    break
                }
                case 2: {
                    if (y % 1 !== 0) {
                        alert("叫你输入整数！")

                    } else {
                        if (y % 4 !== 0) {
                            m = 28;
                            alert(y + "年2月有" + m + "天")
                        } else {
                            m = 29;
                            alert(y + "年2月有" + m + "天")
                        }
                    }
                }
                default:{
                    alert("请输入正确的月份")
                }
            }
        }
    </script>
</head>
<body>
<button onclick="wd()">点击</button>
</body>
</html>